var webpack = require('webpack')
var path = require('path')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var htmlWebpackPlugin = require('html-webpack-plugin')


var mymodule =  {

  entry: path.resolve(__dirname, 'src', 'main.js'),

  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },

  module: {
    loaders: [
      //...
    ]
  },

}

if (process.env.NODE_ENV === 'prod') {
  mymodule.module.loaders.push({
    test: /\.css$/,
    loader: ExtractTextPlugin.extract('style', 'css')
  })
  mymodule.plugins = (mymodule.plugins || []).concat([
    new ExtractTextPlugin('[name].css'),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      },
      except: ['$super', '$', 'exports', 'require']    //排除关键字
    }),
    new htmlWebpackPlugin({
      title: '打包后的'
    })
  ])
} else if (process.env.NODE_ENV === 'dev') {
  mymodule.output.publicPath = '/dist/'
  mymodule.module.loaders.push({
    test: /\.css$/,
    loader: 'style!css'
  })
}

module.exports = mymodule